<template>
  <BasicTable @register="registerTable"></BasicTable>
</template>
<script lang="ts" name="sysop-query" setup>
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { BasicColumn, FormSchema } from '/@/components/Table';
import dayjs, { Dayjs } from 'dayjs';
type RangeValue = [Dayjs, Dayjs];
import { ref } from 'vue';
import { list } from './data.api'


const searchFormSchema: FormSchema[] = [
  {
    label: '关键词',
    field: 'logContent',
    component: 'Select',
    componentProps: {
      mode: "tags"
    }
  },
  {
    label: '项目',
    field: 'serviceId',
    component: 'Input',
  },
  {
    field: 'fieldTime',
    component: 'RangePicker',
    label: '时间范围',
    componentProps: {
      valueType: 'Date',
      ranges: {
        '最近10分钟': [dayjs().subtract(10, 'minutes'), dayjs()],
        '最近20分钟': [dayjs().subtract(10, 'minutes'), dayjs()],
        '最近30分钟': [dayjs().subtract(30, 'minutes'), dayjs()],
        '最近1小时': [dayjs().subtract(1, 'hour'), dayjs()],
        '最近2小时': [dayjs().subtract(1, 'hour'), dayjs()],
        '最近3小时': [dayjs().subtract(3, 'hour'), dayjs()],
        '最近12小时': [dayjs().subtract(12, 'hour'), dayjs()],
        '最近1天': [dayjs().subtract(1, 'days'), dayjs()],
        '最近2天': [dayjs().subtract(2, 'days'), dayjs()],
        '最近3天': [dayjs().subtract(3, 'days'), dayjs()],
        '最近7天': [dayjs().subtract(7, 'days'), dayjs()],
      },
      showTime: true,
      format: "YYYY/MM/DD HH:mm:ss",
    },


  },
]

//定义表格列字段
const columns: BasicColumn[] = [
  {
    title: '时间',
    dataIndex: 'createTime',
    key: 'createTime',
  },
  {
    title: '项目',
    dataIndex: 'logType',
    key: 'logType',
  },
  {
    title: '日志',
    dataIndex: 'logContent',
    key: 'logContent',
  },
];



const { tableContext } = useListPage({
  designScope: 'user-list',
  tableProps: {
    title: '业务日志查询',
    api: list,
    formConfig: {
      schemas: searchFormSchema,
      fieldMapToTime: [['fieldTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
    },
    columns: columns,
    showActionColumn: false,
    fetchSetting: {
      pageField: 'page',
      sizeField: 'size',
      listField: 'content',
      totalField: 'totalElements'
    },
    handleSearchInfoFn: (e) => {
      console.log(e,'--------------e6666666666666------------------')
    }
  }
})

const [registerTable, { reload }] = tableContext;




</script>
<style ></style>
